﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace HTComics.Data
{
    public class Misc
    {
        public static double GetGlobalDiscount()
        {
            double discount = 0;
            DataTable dtDiscount = Common.GetDataTable("SP_GET_GLOBAL_DISCOUNT");

            if (dtDiscount.Rows.Count > 0 && dtDiscount.Rows[0][0] != DBNull.Value)
                discount = Convert.ToDouble(dtDiscount.Rows[0][0]);

            return discount;
        }

        public static DataTable GetDiscountDetails()
        {
            return Common.GetDataTable("SP_GET_DISCOUNT_DETAILS");
        }

        public static DataTable GetPriceBands()
        {
            return Common.GetDataTable("SP_GET_PRICE_BANDS");
        }

        public static DataTable GetPriceGuide()
        {
            return Common.GetDataTable("SP_GET_PRICE_GUIDE");
        }

        public static DataTable GetConditionTypes()
        {
            return Common.GetDataTable("SP_GET_CONDITION_TYPES");
        }

        public static void GetStats(out int totalComics, out int totalIssues, out int discount)
        {
            DataSet dsStats = Common.GetDataSet("SP_GET_STATS"); 
            totalComics = totalIssues = discount = 0;

            totalComics = Convert.ToInt32(dsStats.Tables[0].Rows[0][0].ToString());
            totalIssues = Convert.ToInt32(dsStats.Tables[1].Rows[0][0].ToString());
            discount = Convert.ToInt32(dsStats.Tables[2].Rows[0][0].ToString());
        }

        public static DataTable GetForexRate()
        {
            return Common.GetDataTable("SP_GET_FOREX_RATE");;
        }
    }
}
